home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-04
/
bipl.zip
/
PROCS.ZIP
/
FILEDIM.ICN
< prev
next >
Wrap
Text File
|
1992-09-28
|
947b
|
42 lines
############################################################################
#
# File: filedim.icn
#
# Subject: Procedure to compute file dimensions
#
# Author: Ralph E. Griswold
#
# Date: August 1, 1992
#
###########################################################################
#
# filedim(s, p) computes the number of rows and maximum column width
# of the file named s. The procedure p, which defaults to detab, i
# applied to each line. For example, to have lines left as is, use
#
# filedim(s, 1)
#
############################################################################
record textdim(cols, rows)
procedure filedim(s, p)
local input, rows, cols
/p := detab
input := open(s) | stop("*** cannot open ", s)
rows := cols := 0
while line := p(read(input)) do {
rows +:= 1
cols <:= *line
}
close(input)
return textdim(cols, rows)
end